﻿#region Copyright(C) 2018 FI Ltd. All rights reserved.
// ==================================================================================================
// Copyright(C) 2018 FI Ltd. All rights reserved.
//
// SYSTEM NAME	    : FI.Net Application Framework
// COMPONENT ID	    : FI.Core
// COMPONENT DESC   : FI.Net Core Foundation
//
// CREATED DATE/BY  : 18 Aug 2018 / Tian Mi
//
// REVISION HISTORY :	
// DATE/BY			SR#/CS/PM#/OTHERS		DESCRIPTION OF CHANGE
// ==================================================================================================
#endregion

using FI.Core.Utilities;
using System.Runtime.Serialization;

namespace FI.Core
{
    /// <summary>
    /// A entity with <see cref="AuditInfo"/>.
    /// </summary>
    /// <typeparam name="T">The data type of internal data entry.</typeparam>
    [DataContract(Namespace = Constants.Namespace, Name="AuditableOf{0}")]
    public class Auditable<T>
    {
        /// <summary>
        /// Gets or sets the data.
        /// </summary>
        /// <value>
        /// The data.
        /// </value>
        [DataMember]
        public T Entry { get; set; }

        /// <summary>
        /// Gets or sets the audit info.
        /// </summary>
        /// <value>
        /// The audit info.
        /// </value>
        [DataMember]
        public AuditInfo AuditInfo { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="Auditable{T}"/> class.
        /// </summary>
        public Auditable()
        {
            this.AuditInfo = new AuditInfo();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Auditable{T}" /> class.
        /// </summary>
        /// <param name="entry">The entry.</param>
        public Auditable(T entry):this()
        {
            Guard.ArgumentNotNull(entry, "entry");
            this.Entry = entry;
        }
    }
}
